 <?PHP
     $tagID=1;
     if(!empty($_GET["tag"])){
         $tagID=$_GET["tag"];
         $R_MoudeTagID=$_GET["MoudeTagID"];
         $R_Page=$_GET["page"];
     }else if(!empty($_POST["tag"])){
         $tagID=$_POST["tag"];
         $R_MoudeTagID=$_POST["MoudeTagID"];
         $R_Page=$_POST["page"];
     }
     if(isset($R_MoudeTagID)&&$_SESSION["User_Admin"]==1){
       if(isset($R_Del)){
           if($R_Del=="1"){
             $sql="delete from tagmodule where ID=$R_MoudeTagID";
             $_rd= mysql_query($sql,$_db_link);
           }
       }else if($_GET["down"]=="1"){
         $sql="update tagmodule set Sorting=Sorting+1 where TagID=$tagID and Sorting=".($_GET["Sorting"]-1). " and Postion=".$_GET["Postion"];
         $_rd= mysql_query($sql,$_db_link);
         $sql="update tagmodule set Sorting=Sorting-1 where id=$R_MoudeTagID";
         mysql_query($sql,$_db_link);
       }else if($_GET["up"]=="1"){
         $sql="update tagmodule set Sorting=Sorting-1 where TagID=$tagID and Sorting=".($_GET["Sorting"]+1). " and Postion=".$_GET["Postion"];
         $_rd= mysql_query($sql,$_db_link);
         $sql="update tagmodule set Sorting=Sorting+1 where id=$R_MoudeTagID";
         mysql_query($sql,$_db_link);
       }
     }
     $sql="select * from tagrol where tagid=$tagID";
     $_rd= mysql_query($sql,$_db_link);
     $_sw_tag=0;
     while($data = mysql_fetch_array($_rd, MYSQL_ASSOC)){
        if(UserHatRolID($data["RolID"])){
            $_sw_tag=1;
            break;
        }
     }
     $sql="select tagmodule.ID,tagmodule.Postion,tagmodule.Titel,tagmodule.Setting,tagmodule.Sorting
           ,module.Adresse as Adresse1
           ,modulepage.Adresse as Adresse2
           from tagmodule,module,modulepage
           where tagmodule.TagID=$tagID and tagmodule.Visible=1 and tagmodule.ModuleID=module.ID and  module.MainPageID=modulepage.ID
           ORDER BY sorting desc";
     $L_rd= mysql_query($sql,$_db_link);
     $L_datalength=0;
     while(($data = mysql_fetch_array($L_rd, MYSQL_ASSOC))&& $_sw_tag==1){
       $L_data[]=$data;
       $L_datalength++;
     }
     $strCenter="";
     for($_i=0;$_i<$L_datalength;$_i++){
         if($L_data[$_i]["Postion"]==4){
             $Setting=$L_data[$_i]["Setting"];
             $MoudeTagID=$L_data[$_i]["ID"];
             $Sorting=$L_data[$_i]["Sorting"];
             $strCenter=$strCenter+'<div class="centeroben">
    <table class="titeltable">
        <tr>
          <td class="titelleft"></td>
          <td class="TitelCenter">
            <h2>'.$L_data[$_i]["Titel"].'</h2>
          </td>
          <td class="TitelRight"></td>';
          if($_SESSION["User_Admin"]==1){
             if($_i!=0) {
              $strCenter=$strCenter+"<td><a href='index.php?tag=$tagID&MoudeTagID=$MoudeTagID&up=1&Sorting=$Sorting&Postion=".$L_data[$_i]["Postion"]."><img src=;phpimages/up.png' border='0'></td>";
             }
             if($_i!=$L_datalength-1){
                 $strCenter=$strCenter+"<td><a href='index.php?tag=$tagID&MoudeTagID=$MoudeTagID&down=1&Sorting=$Sorting&Postion=".$L_data[$_i]["Postion"]."><img src='phpimages/down.png' border='0'></a></td>";
             }
             $strCenter=$strCenter+"<td><a href='index.php?tag=$tagID&MoudeTagID=$MoudeTagID&del=1'><img src='phpimages/delete.png' border='0'></a></td>";
          }
        $strCenter=$strCenter+"
      </tr>
     </table>
</div>
<div class='box'>
  <table class='titeltable' width=100%>
    <tr>
      <td class='boxtopleft'>z</td>
      <td class='boxtop'>z</td>
      <td class='boxtopright'>z</td>
    </tr>
    <tr>
      <td class='boxcenterleft'>z</td>
      <td class='boxcenter'>
          <form method='POST' id='addForm' action=''>";
          if($R_MoudeTagID == $MoudeTagID && $R_Page!="" ){
              
              include($L_data[$_i]["Adresse1"].$R_Page.".php");
          }else{
              
              include($L_data[$_i]["Adresse1"].$L_data[$_i]["Adresse2"].".php");
          }
        $strCenter=$strCenter+'</form>
      </td>
      <td class="boxtopright">z</td>
    </tr>
    <tr>
      <td class="boxtopleft">z</td>
      <td class="boxtop">z</td>
      <td class="boxtopright">z</td>
    </tr>
  </table>
</div>';

      }
    }
